home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / p_man / cat3 / Xm / XmResolvePartOffsets.z / XmResolvePartOffsets
Encoding:
Text File  |  2002-10-03  |  8.0 KB  |  199 lines

  1.  
  2.  
  3.  
  4.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.           XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss - A function that allows writing of
  10.           upward-compatible applications and widgets
  11.  
  12.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  13.           #include <Xm/Xm.h>
  14.           vvvvooooiiiidddd XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss(
  15.           WWWWiiiiddddggggeeeettttCCCCllllaaaassssssss wwwwiiiiddddggggeeeetttt____ccccllllaaaassssssss,
  16.           XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr **** ooooffffffffsssseeeetttt);
  17.  
  18.      VVVVEEEERRRRSSSSIIIIOOOONNNN
  19.           This page documents Motif 2.1.
  20.  
  21.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  22.           The use of offset records requires one extra global variable
  23.           per widget class.  The variable consists of a pointer to an
  24.           array of offsets into the widget record for each part of the
  25.           widget structure.  The XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss function
  26.           allocates the offset records needed by an application to
  27.           guarantee upward-compatible access to widget instance
  28.           records by applications and widgets.  These offset records
  29.           are used by the widget to access all of the widget's
  30.           variables.  A widget needs to take the steps described in
  31.           the following paragraphs.
  32.  
  33.           Instead of creating a resource list, the widget creates an
  34.           offset resource list.  To accomplish this, use the
  35.           XXXXmmmmPPPPaaaarrrrttttRRRReeeessssoooouuuurrrrcccceeeestructure and the XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt macro.  The
  36.           XXXXmmmmPPPPaaaarrrrttttRRRReeeessssoooouuuurrrrcccceeee data structure looks just like a resource
  37.           list, but instead of having one integer for its offset, it
  38.           has two shorts.  This structure is put into the class record
  39.           as if it were a normal resource list. Instead of using
  40.           XXXXttttOOOOffffffffsssseeeetttt for the offset, the widget uses XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt.
  41.  
  42.           XmPartResource resources[] = {
  43.             { BarNxyz, BarCXyz, XmRBoolean,
  44.               sizeof(Boolean), XmPartOffset(Bar,xyz),
  45.               XmRImmediate, (XtPointer)False }
  46.           };
  47.  
  48.           Instead of putting the widget size in the class record, the
  49.           widget puts the widget part size in the same field.
  50.  
  51.           Instead of putting XXXXttttVVVVeeeerrrrssssiiiioooonnnn in the class record, the widget
  52.           puts XXXXttttVVVVeeeerrrrssssiiiioooonnnnDDDDoooonnnnttttCCCChhhheeeecccckkkk in the class record.
  53.  
  54.           The widget defines a variable, of type XXXXmmmmOOOOffffffffsssseeeettttPPPPttttrrrr, to point
  55.           to the offset record.  This can be part of the widget's
  56.           class record or a separate global variable.
  57.  
  58.           In class initialization, the widget calls
  59.           XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss, passing it a pointer to contain the
  60.  
  61.  
  62.  
  63.      Page 1                                          (printed 10/3/02)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  71.  
  72.  
  73.  
  74.           address of the offset record and the class record.  This
  75.           does several things:
  76.  
  77.              +o  Adds the superclass (which, by definition, has already
  78.                 been initialized) size field to the part size field
  79.  
  80.              +o  Allocates an array based upon the number of
  81.                 superclasses
  82.  
  83.              +o  Fills in the offsets of all the widget parts with the
  84.                 appropriate values, determined by examining the size
  85.                 fields of all superclass records
  86.  
  87.              +o  Uses the part offset array to modify the offset
  88.                 entries in the resource list to be real offsets, in
  89.                 place
  90.  
  91.           The widget defines a constant that will be the index to its
  92.           part structure in the offsets array.  The value should be 1
  93.           greater than the index of the widget's superclass.
  94.           Constants defined for all XXXXmmmmwidgets can be found in XXXXmmmmPPPP....hhhh.
  95.  
  96.           #define BarIndex (XmBulletinBIndex + 1)
  97.  
  98.           Instead of accessing fields directly, the widget must always
  99.           go through the offset table.  The XXXXmmmmFFFFiiiieeeelllldddd macro helps you
  100.           access these fields.  Because the XXXXmmmmPPPPaaaarrrrttttOOOOffffffffsssseeeetttt and
  101.           XXXXmmmmFFFFiiiieeeellllddddmacros concatenate things together, you must ensure
  102.           that there is no space after the part argument.  For
  103.           example, the following macros do not work because of the
  104.           space after the part (Label) argument:
  105.  
  106.           XmField(w, offset, Label, text, char *)
  107.           XmPartOffset(Label, text)
  108.  
  109.           Therefore, you must not have any spaces after the part
  110.           (Label) argument, as illustrated here:
  111.  
  112.           XmField(w, offset, Label, text, char *)
  113.  
  114.           You can define macros for each field to make this easier.
  115.           Assume an integer field _x_y_z:
  116.  
  117.           #define BarXyz(w) (*(int *)(((char *) w) + \
  118.                   offset[BarIndex] + XtOffset(BarPart,xyz)))
  119.  
  120.           The parameters for XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss are
  121.  
  122.           _w_i_d_g_e_t__c_l_a_s_s
  123.                     Specifies the widget class pointer for the created
  124.                     widget
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                                          (printed 10/3/02)
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.      XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))  UUUUNNNNIIIIXXXX SSSSyyyysssstttteeeemmmm VVVV  XXXXmmmmRRRReeeessssoooollllvvvveeeePPPPaaaarrrrttttOOOOffffffffsssseeeettttssss((((3333XXXX))))
  137.  
  138.  
  139.  
  140.           _o_f_f_s_e_t    Returns the offset record
  141.  
  142.      RRRREEEELLLLAAAATTTTEEEEDDDD IIIINNNNFFFFOOOORRRRMMMMAAAATTTTIIIIOOOONNNN
  143.           XXXXmmmmRRRReeeessssoooollllvvvveeeeAAAAllllllllPPPPaaaarrrrttttOOOOffffffffsssseeeettttssss(3).
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.      Page 3                                          (printed 10/3/02)
  196.  
  197.  
  198.  
  199.